-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select connector type before name #11388
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small proposal for change.
*/ | ||
const SetDefaultName: React.FC<{ | ||
availableConnectors: ConnectorDefinition[]; | ||
}> = ({ availableConnectors }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing availableConnectors
and searching - you could use useServiceForm
hook that has selectedService
prop.
So this method will shorten to something like
const { selectedService } = useServiceForm();
const [,,helpers] = useField("name");
useEffect(() => {
const name = selectedService?.name ?? "";
helpers.setValue(name);
}, [selectedService, helpers]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I will use useServiceForm
here.
I tried using useField
initially, but the problem is that the helpers it's returning isn't a stable reference, thus causing this useEffect
to trigger in an endless loop, thus using the setFieldValue
here instead (which is a stable reference).
What
Closes #11261
This will pull the connector type before the name box (and hide the name input as long as no connector is selected). It will also cause the name to become the connector definition name by default when it's switched.
Peek.2022-03-24.12-18.mp4